// 当前时间的前7天
export function getentDate() {
  const date = new Date();
  let Y = date.getFullYear();
  let M = date.getMonth() + 1;
  let D = date.getDate() - 6;
  if (D <= 0) {
    M = date.getMonth();
    var d1 = new Date(Y, M, 0);
    var d2 = d1.getDate();
    M = M < 10 ? '0' + M : M;
    D = d2 + D < 10 ? '0' + (d2 + D) : d2 + D;
    return Y + '-' + M + '-' + D + ' 00:00:00';
  } else {
    M = M < 10 ? '0' + M : M;
    D = D < 10 ? '0' + D : D;
    return Y + '-' + M + '-' + D + ' 00:00:00';
  }
}
// 当前时间的前七天
export function getDateSeven() {
  const date = new Date();
  let Y = date.getFullYear();
  let M = date.getMonth() + 1;
  let D = date.getDate() - 6;
  if (D < 0) {
    M = date.getMonth();
    var d1 = new Date(Y, M, 0);
    var d2 = d1.getDate();
    M = M < 10 ? '0' + M : M;
    D = d2 + D < 10 ? '0' + (d2 + D) : d2 + D;
    return Y + '-' + M + '-' + D;
  } else {
    M = M < 10 ? '0' + M : M;
    D = D < 10 ? '0' + D : D;
    return Y + '-' + M + '-' + D;
  }
}
// 获取当前时间 年月日时分秒
export function getDateTimes() {
  const dates = new Date();
  let Y = dates.getFullYear();
  let M = dates.getMonth() + 1;
  let D = dates.getDate();
  let h = dates.getHours();
  let mi = dates.getMinutes();
  let s = dates.getSeconds();
  M = M < 10 ? '0' + M : M;
  D = D < 10 ? '0' + D : D;
  h = h < 10 ? '0' + h : h;
  mi = mi < 10 ? '0' + mi : mi;
  s = s < 10 ? '0' + s : s;
  return Y + '-' + M + '-' + D + ' ' + h + ':' + mi + ':' + s;
}

// 获取本月第一天
export function getDateOne() {
  const dates = new Date();
  let Y = dates.getFullYear();
  let M = dates.getMonth() + 1;
  M = M < 10 ? '0' + M : M;
  return Y + '-' + M + '-' + '01 00:00:00';
}

// 获取当前时间 年月日
export function getDatenyr() {
  const dates = new Date();
  let Y = dates.getFullYear();
  let M = dates.getMonth() + 1;
  let D = dates.getDate();
  M = M < 10 ? '0' + M : M;
  D = D < 10 ? '0' + D : D;
  return Y + '-' + M + '-' + D;
}

// 获取当前时间 年月日
export function getDateT() {
  const dates = new Date();
  let Y = dates.getFullYear();
  let M = dates.getMonth() + 1;
  let D = dates.getDate();
  M = M < 10 ? '0' + M : M;
  D = D < 10 ? '0' + D : D;
  return Y + '-' + M + '-' + D + ' 12:00:00';
}
// 当前时间的前一天
export function getDateqOne() {
  const date = new Date();
  let qytdate = new Date(date.getTime() - 24 * 60 * 60 * 1000);
  let Y = qytdate.getFullYear();
  let M = qytdate.getMonth() + 1;
  let D = qytdate.getDate();
  M = M < 10 ? '0' + M : M;
  D = D < 10 ? '0' + D : D;
  return Y + '-' + M + '-' + D + ' 12:00:00';
}
// 当前时间的后一天
export function getDatehOne() {
  const date = new Date();
  let hytdate = new Date(date.getTime() + 24 * 60 * 60 * 1000);
  let Y = hytdate.getFullYear();
  let M = hytdate.getMonth() + 1;
  let D = hytdate.getDate();
  M = M < 10 ? '0' + M : M;
  D = D < 10 ? '0' + D : D;
  return Y + '-' + M + '-' + D + ' 11:59:59';
}
